<template>
    <!-- 中间内容 -->
    <div class="container">
        <!-- 顶部banner -->
        <div class="banner">
            <div class="nav">
                <a href="#">全部商品分类</a>
                <a href="">戏剧 </a>
                <a href="">体育</a>
                <a href="">亲子</a>
                <a href="">摇滚</a>
                <a href="">舞蹈古典</a>
            </div>
            <div class="banner-main">
                <ul class="ul-nav">
                    <li><a href="">演唱会</a> </li>
                    <li><a href="">音乐会</a> </li>
                    <li><a href="">曲苑杂坛</a> </li>
                    <li><a href="">话剧歌剧</a> </li>
                    <li><a href="">体育比赛</a> </li>
                    <li><a href="">舞蹈芭蕾</a> </li>
                    <li><a href="">儿童亲子</a> </li>
                    <li><a href="">动漫</a> </li>
                </ul>
                <img src="@/assets/img/index1/banner.png" alt="">
                <div>
                    <a href="#">01.浪漫辉煌四十年— 理查德·克</a>
                    <a href="#">02.2018第三届人民大会堂·北京</a>
                    <a href="#">03.开心麻花2018报销贺岁舞台</a>
                </div>
            </div>

        </div>

        <!-- 热门推荐 -->
        <div class="hot">
            <h4>热门推荐</h4>
            <ul class="hot-ul">
                <li class="hot-item"
                    v-for="(item, index) in goodsData.slice(0, 6)" :key="index">
                    <router-link :to="{name:'detail',query:{id:item.id}}">
                        <img :src='item.img_src' alt="" class="hot-img">
                        <p class="hot-infor">{{item.good_name}}</p>
                        <p class="hot-price">
                            票价：<span>{{Array.isArray(item.price)?item.price[0]:item.price}}
                            </span> 起</p>
                    </router-link>
                </li>
            </ul>
        </div>

        <!-- 主体内容 -->
        <div class="main">
            <div class="main-box" v-for="(t, index) in types" :key="index">
                <div class="main-left">
                    <span class="main-num">{{index+1}}F</span> <span
                        class="main-title">{{t.name}}</span>
                    <div class="main-item">
                        <img :src="goodsData[index]?.img_src" alt="">
                        <ul class="main-ul">
                            <li v-for="(e, i) in goodsData.slice(index+1,index+5)"
                                :key="i">
                                <router-link :to="`/detail?id=${e.id}`">
                                    <img :src="e?.img_src" alt="">
                                    <div>
                                        <p>{{e.good_name}}</p>
                                        <div>
                                            <p>{{e.play_time}}</p>
                                            <p>{{e.place}}</p>
                                            <p>¥{{Array.isArray(e.price)?e.price[0]:e.price}}起
                                            </p>
                                        </div>
                                    </div>
                                </router-link>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="main-right">
                    <h4>热门{{t.name}}</h4>
                    <ul>
                        <li v-for="(list, index) in goodsData.slice(0,10)"
                            :key="index">
                            <router-link :to="`/details?id=${list.id}`">
                                <span>{{list.id}}</span>{{list.good_name}}
                            </router-link>
                        </li>
                    </ul>
                    <img :src="goodsData[index]?.img_src" alt="">
                </div>
            </div>
        </div>
    </div>

    <!-- 只有背景图 -->
    <div class="sidebar">
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import axios from 'axios'

const goodsData = ref([])
const types = ref([])

onMounted(() => {
    axios.get('/goodDetail').then((res) => {
        console.log(res.data.goods);
        goodsData.value = res.data.goods
    })

    axios.get('/types').then((res) => {
        console.log(res.data.types);
        types.value = res.data.types
    })


})

</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}
li {
    list-style: none;
}
a {
    text-decoration: none;
    color: black;
}
body {
    background-color: #f5f5f5;
}
.container {
    width: 1200px;
    margin: 46px auto 160px;
    .banner {
        height: 470px;
        background-color: #fff;
        .nav {
            height: 52px;
            line-height: 52px;
            width: 100%;
            display: flex;
            a {
                font-size: 16px;
                display: block;
                text-align: center;
                width: 110px;
                &:hover {
                    background-color: #ff3c1b;
                    color: #fff;
                }
                &:first-child {
                    width: 202px;
                    background-color: #000000;
                    color: white;
                }
            }
        }
        .banner-main {
            display: flex;
            position: relative;
            .ul-nav {
                background-color: #ff3c1b;
                width: 202px;
                height: 420px;
                overflow: hidden;
                li {
                    line-height: 50px;
                    height: 50px;
                    padding-left: 68px;
                    background: url(~@/assets/img/index1/sprite.png) no-repeat;
                    &:first-child {
                        margin-top: 8px;
                        background-position: 28px 12px;
                    }
                    &:nth-child(2) {
                        background-position: 28px -38px;
                    }
                    &:nth-child(3) {
                        background-position: 28px -88px;
                    }
                    &:nth-child(4) {
                        background-position: 28px -138px;
                    }
                    &:nth-child(5) {
                        background-position: 28px -188px;
                    }
                    &:nth-child(6) {
                        background-position: 28px -238px;
                    }
                    &:nth-child(7) {
                        background-position: 28px -288px;
                    }
                    &:nth-child(8) {
                        background-position: 28px -338px;
                    }
                    &:hover {
                        background-color: #de290a;
                    }
                    a {
                        display: block;
                        color: #fff;
                    }
                }
            }
            > div {
                position: absolute;
                bottom: 0;
                right: 0;
                background-color: rgba(12, 12, 12, 0.62);
                width: 998px;
                height: 50px;
                line-height: 50px;
                font-size: 14px;
                a {
                    padding: 0 32px;
                    color: white;
                }
            }
        }
    }
    .hot {
        margin-top: 30px;
        height: 352px;
        background-color: white;
        padding: 24px 31px;
        h4 {
            font-size: 18px;
            font-weight: normal;
        }
        .hot-ul {
            margin-top: 34px;
            display: flex;
            justify-content: space-between;
            .hot-item {
                width: 146px;
                font-size: 12px;
                .hot-img {
                    width: 146px;
                    height: 192px;
                }
                .hot-infor {
                    margin-top: 15px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
                .hot-price {
                    margin-top: 10px;
                    color: #999999;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    span {
                        color: #000000;
                    }
                }
            }
        }
    }
    .main {
        .main-box {
            display: flex;
            justify-content: space-between;
            margin-top: 30px;
            .main-left {
                width: 895px;
                height: 466px;
                background-color: white;
                padding: 21px 26px;
                box-sizing: border-box;
                .main-num {
                    color: #ff3c1b;
                    font-size: 20px;
                }
                .main-title {
                    font-size: 16px;
                }
                .main-item {
                    margin-top: 21px;
                    display: flex;
                    > img {
                        width: 235px;
                        height: 360px;
                        background-color: red;
                        // margin-right: 35px;
                    }
                    .main-ul {
                        // display: flex;
                        // background-color: blue;
                        li {
                            float: left;
                            width: 272px;
                            height: 151px;
                            margin-left: 30px;
                            margin-bottom: 60px;
                            > a {
                                display: flex;
                                font-size: 12px;
                                > img {
                                    width: 112px;
                                    height: 151px;
                                }
                                > div {
                                    width: 160px;
                                    margin-left: 9px;
                                    display: flex;
                                    flex-direction: column;
                                    justify-content: space-between;
                                    > p {
                                        line-height: 18px;
                                    }
                                    > div {
                                        color: #999999;
                                        line-height: 28px;
                                        > p {
                                            overflow: hidden;
                                            text-overflow: ellipsis;
                                            white-space: nowrap;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            .main-right {
                width: 280px;
                height: 466px;
                background-color: white;
                box-sizing: border-box;
                padding: 20px 25px;
                h4 {
                    font-size: 18px;
                    font-weight: normal;
                }
                ul {
                    width: 238px;
                    margin-top: 22px;
                    li {
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        a {
                            text-decoration: none;
                            color: black;
                        }
                        line-height: 28px;
                        font-size: 12px;
                        &:nth-child(-n + 3) {
                            span {
                                background-color: #ff3c1b;
                            }
                        }
                        &:last-child {
                            span {
                                padding: 0 5px;
                            }
                        }
                        span {
                            // display: inline-block;
                            padding: 0 8px;
                            margin-right: 10px;
                            height: 12px;
                            color: white;
                            background-color: #a5a5a5;
                        }
                    }
                }
                img {
                    width: 230px;
                    height: 98px;
                    margin-top: 6px;
                    background-color: #a5a5a5;
                }
            }
        }
    }
}
.sidebar {
    width: 42px;
    height: 185px;
    position: fixed;
    top: 30%;
    right: 125px;
    border-radius: 21px;
    background: url(~@/assets/img/index1/sprite.png);
    background-color: #ffffff;
    background-position: 9px -412px;
}
</style>